Skip to content

Conversation

@xlauko
Copy link
Contributor

@xlauko xlauko commented Dec 8, 2025

This had to fix memory and conversion bugs due to now immediate
conversion patterns and no longer present original MLIR.

@xlauko
Copy link
Contributor Author

xlauko commented Dec 8, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 8e2b47dbe..52455fdc4 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -1129,7 +1129,6 @@ mlir::LogicalResult CIRToLLVMBrCondOpLowering::matchAndRewrite(
   // ZExtOp and if so, delete it if it has a single use.
   assert(!cir::MissingFeatures::zextOp());
 
-  
   rewriter.replaceOpWithNewOp<mlir::LLVM::CondBrOp>(
       brOp, adaptor.getCond(), brOp.getDestTrue(),
       adaptor.getDestOperandsTrue(), brOp.getDestFalse(),
@@ -3781,7 +3780,7 @@ mlir::LogicalResult CIRToLLVMComplexRealOpLowering::matchAndRewrite(
         rewriter, op.getLoc(), resultLLVMTy, operand,
         llvm::ArrayRef<std::int64_t>{0});
   }
- 
+
   rewriter.replaceOp(op, operand);
   return mlir::success();
 }

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

🐧 Linux x64 Test Results

  • 85773 tests passed
  • 758 tests skipped
  • 2 tests failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.CIR/CodeGen/complex-compound-assignment.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# note: command had no output on stdout or stderr
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=CIR,CXX_CIR
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=CIR,CXX_CIR
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -check-prefix=CIR
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -check-prefix=CIR
# note: command had no output on stdout or stderr
# RUN: at line 5
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# note: command had no output on stdout or stderr
# RUN: at line 6
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=LLVM,CXX_LLVM
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=LLVM,CXX_LLVM
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp:198:10: error: LLVM: expected string not found in input
# | // LLVM: %[[RESULT_REAL:.*]] = extractvalue { float, float } %[[RESULT]], 0
# |          ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:89:54: note: scanning from here
# |  %24 = insertvalue { float, float } %23, float %22, 1
# |                                                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:89:54: note: with "RESULT" equal to "24"
# |  %24 = insertvalue { float, float } %23, float %22, 1
# |                                                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:125:2: note: possible intended match here
# |  %5 = extractvalue { float, float } %4, 0
# |  ^
# | 
# | Input file: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |             84:  %19 = extractvalue { float, float } %9, 0 
# |             85:  %20 = extractvalue { float, float } %9, 1 
# |             86:  %21 = fadd float %17, %19 
# |             87:  %22 = fadd float %18, %20 
# |             88:  %23 = insertvalue { float, float } poison, float %21, 0 
# |             89:  %24 = insertvalue { float, float } %23, float %22, 1 
# | check:198'0                                                          X error: no match found
# | check:198'1                                                            with "RESULT" equal to "24"
# |             90:  %25 = fptrunc float %21 to half 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             91:  %26 = fptrunc float %22 to half 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             92:  %27 = insertvalue { half, half } undef, half %25, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             93:  %28 = insertvalue { half, half } %27, half %26, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             94:  store { half, half } %28, ptr %2, align 2 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |            120: define dso_local void @_Z4foo5v() #0 { 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            121:  %1 = alloca { float, float }, i64 1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            122:  %2 = alloca float, i64 1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            123:  %3 = load float, ptr %2, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            124:  %4 = load { float, float }, ptr %1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            125:  %5 = extractvalue { float, float } %4, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:198'2      ?                                         possible intended match
# |            126:  %6 = extractvalue { float, float } %4, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            127:  %7 = fadd float %5, %3 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |            128:  %8 = insertvalue { float, float } undef, float %7, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            129:  %9 = insertvalue { float, float } %8, float %6, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            130:  store { float, float } %9, ptr %1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

Clang.CIR/CodeGen/complex-compound-assignment.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# note: command had no output on stdout or stderr
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=CIR,CXX_CIR
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=CIR,CXX_CIR
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -x c -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -check-prefix=CIR
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp.cir /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -check-prefix=CIR
# note: command had no output on stdout or stderr
# RUN: at line 5
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/22/include -nostdsysteminc -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# note: command had no output on stdout or stderr
# RUN: at line 6
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=LLVM,CXX_LLVM
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp --check-prefixes=LLVM,CXX_LLVM
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp:198:10: error: LLVM: expected string not found in input
# | // LLVM: %[[RESULT_REAL:.*]] = extractvalue { float, float } %[[RESULT]], 0
# |          ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:89:54: note: scanning from here
# |  %24 = insertvalue { float, float } %23, float %22, 1
# |                                                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:89:54: note: with "RESULT" equal to "24"
# |  %24 = insertvalue { float, float } %23, float %22, 1
# |                                                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll:125:2: note: possible intended match here
# |  %5 = extractvalue { float, float } %4, 0
# |  ^
# | 
# | Input file: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/CIR/CodeGen/Output/complex-compound-assignment.cpp.tmp-cir.ll
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CIR/CodeGen/complex-compound-assignment.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |             84:  %19 = extractvalue { float, float } %9, 0 
# |             85:  %20 = extractvalue { float, float } %9, 1 
# |             86:  %21 = fadd float %17, %19 
# |             87:  %22 = fadd float %18, %20 
# |             88:  %23 = insertvalue { float, float } poison, float %21, 0 
# |             89:  %24 = insertvalue { float, float } %23, float %22, 1 
# | check:198'0                                                          X error: no match found
# | check:198'1                                                            with "RESULT" equal to "24"
# |             90:  %25 = fptrunc float %21 to half 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             91:  %26 = fptrunc float %22 to half 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             92:  %27 = insertvalue { half, half } undef, half %25, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             93:  %28 = insertvalue { half, half } %27, half %26, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             94:  store { half, half } %28, ptr %2, align 2 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |            120: define dso_local void @_Z4foo5v() #0 { 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            121:  %1 = alloca { float, float }, i64 1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            122:  %2 = alloca float, i64 1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            123:  %3 = load float, ptr %2, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            124:  %4 = load { float, float }, ptr %1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            125:  %5 = extractvalue { float, float } %4, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:198'2      ?                                         possible intended match
# |            126:  %6 = extractvalue { float, float } %4, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            127:  %7 = fadd float %5, %3 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |            128:  %8 = insertvalue { float, float } undef, float %7, 0 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            129:  %9 = insertvalue { float, float } %8, float %6, 1 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            130:  store { float, float } %9, ptr %1, align 4 
# | check:198'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

This had to fix memory and conversion bugs due to now immediate
conversion patterns and no longer present original MLIR.
@xlauko xlauko force-pushed the users/xlauko/cir-personality-functions branch from 68ca1b8 to 4beab30 Compare December 8, 2025 20:24
@xlauko xlauko force-pushed the users/xlauko/cir-one-shot-conversion branch from b93a2e6 to e3fda2a Compare December 8, 2025 20:24
Comment on lines +3761 to +3777
// FIXME:
// Check if we're extracting from a ComplexCreate that was already lowered
// Pattern: insertvalue(insertvalue(undef, real, 0), imag, 1) -> just use
// 'real'
if (auto secondInsert = operand.getDefiningOp<mlir::LLVM::InsertValueOp>()) {
if (secondInsert.getPosition() == llvm::ArrayRef<int64_t>{1}) {
if (auto firstInsert = secondInsert.getContainer()
.getDefiningOp<mlir::LLVM::InsertValueOp>()) {
if (firstInsert.getPosition() == llvm::ArrayRef<int64_t>{0}) {
// This is the pattern we're looking for - return the real component
// directly
rewriter.replaceOp(op, firstInsert.getValue());
return mlir::success();
}
}
}
}
Copy link
Contributor Author

@xlauko xlauko Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andykaylor @AmrDeveloper I am trying to make this work with one-shot conversion. Though our previous conversion "accidently" made this canonicalization as it queried both nontraslated and translated CIR.
And our lit tests expects this to by applied.

I don't really like to have this kind of folding int CIR-to-LLVM translation, but I am not sure whether we want to skip it completely and let LLVM optimize it, or optimize on CIR level somewhere before, e.g., apply already present fold cir.real(cir.complex.create real imag) -> real.

In fact now I am not sure why it is not applied before.

Same holds for imag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants